package config

import (
	"fmt"
	e "github.com/17683954109/Tiny_GO/error"
	"io"
	"os"
)

type Config struct {
	WorkDir string // 工作目录
	MaxConn int    // 最大连接数
}

var Conf Config

func (t *Config) Init() {
	var conf_file = "./conf/tiny_go.conf"
	conf, err := os.Open(conf_file)
	if err != nil {
		e.New(e.ConfCanNotOpen).GetMsg()
		return
	}
	stat, err := conf.Stat()
	if err != nil {
		e.New(e.ConfCanNotGetStat).GetMsg()
		return
	}
	buf := make([]byte, stat.Size())
	_, err = io.ReadFull(conf, buf)
	if err != nil {
		e.New(e.ConfReadError).GetMsg()
		return
	}
	fmt.Println(string(buf))
}
